const Service = require('egg').Service;

class ArticleService extends Service {
    async article_add(params) {
        const Article = this.ctx.model.Article,
            newArticle = new Article(params);
        return await this.ctx.model.Article.add(newArticle);
    }
    async article_update(aid, params) {
        return await this.ctx.model.Article.update(aid, params);
    }
    async article_det(aid) {
        return await this.ctx.model.Article.findById(aid);
    }
    async article_list(page, size) {
        return await this.ctx.model.Article.findAll(page, size);
    }
    async article_del(aid) {
        return await this.ctx.model.Article.del(aid);
    }
    async add_collect(aid, collect) {
        return await this.ctx.model.Article.addCollect(aid, collect);
    }
    async cut_collect(aid, collect) {
        return await this.ctx.model.Article.cutCollect(aid, collect);
    }
    async add_comment(aid, comment) {
        return await this.ctx.model.Article.addComment(aid, comment);
    }
}

module.exports = ArticleService;